package com.wangyadong.hobby.schedule.jobtask.ath.lesson1.stackqueue;

import com.wangyadong.hobby.schedule.jobtask.ath.common.StdOut;

public class Autoboxing {

    public static void cmp(Integer first, Integer second) {
        if (first < second)
            StdOut.printf("%d < %d\n", first, second);
        else if (first == second)
            StdOut.printf("%d == %d\n", first, second);
        else if (first > second)
            StdOut.printf("%d > %d\n", first, second);
        else
            StdOut.printf("%d and %d are incomparable\n", first, second);
    }

    public static void main(String[] args) {
        cmp(new Integer(42), 43);//1
        cmp(new Integer(42), new Integer(42));//else
        cmp(43, 43);//int 值转integer 在-127~127之间 对象是一个 用等好判断true
        cmp(142, 142);//else
        System.out.println("=================");
        double x1 = 0.0, y1 = -0.0;
        Double a1 = x1, b1 = y1;
        StdOut.println(x1 == y1);
        System.out.println("a1  hashCode  " + a1.hashCode() + "  b1 hashCode " + b1.hashCode());
        StdOut.println(a1.equals(b1));

        double x2 = 0.0 / 0.0, y2 = 0.0 / 0.0;
        Double a2 = x2, b2 = y2;
        StdOut.println(x2 != y2);
        StdOut.println(!a2.equals(b2));
        StdOut.println("相等" + a2.equals(b2));

        //包装类 == 比较的是内存中的地址
        double x3 = 0.0, y3 = 0.0;
        Double a3 = x3, a4 = y3;
        StdOut.println(a3.equals(a4));
    }

}
